package com.doctcloud.hisinfo.ordadm.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.doctcloud.common.core.utils.StringUtils;
import com.doctcloud.hisinfo.histable.domain.ordadm.OrdersDo;
import com.doctcloud.hisinfo.ordadm.mapper.OrdersDoMapper;
import com.doctcloud.hisinfo.ordadm.service.IOrdersService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import java.util.ArrayList;
import java.util.List;

@Service
@Slf4j
public class OrdersImpl extends ServiceImpl<OrdersDoMapper, OrdersDo> implements IOrdersService {
    @Override
    public List<OrdersDo> listPatAll(String patientId, Integer visitId) {
        List<OrdersDo> resList = new ArrayList<>();
        if (StringUtils.isEmpty(patientId)) {
            log.error("参数patientId不得为空");
            System.out.println("参数patientId不得为空");
            return resList;
        }
        if (ObjectUtils.isEmpty(visitId)) {
            log.error("参数visitId不得为空");
            System.out.println("参数visitId不得为空");
            return resList;
        }
        LambdaQueryWrapper<OrdersDo> query = Wrappers.lambdaQuery();
        query.eq(OrdersDo::getPatientId,patientId)
                .eq(OrdersDo::getVisitId,visitId);
        resList = baseMapper.selectList(query);
        return resList;
    }
}
